(* scene.ml
 *
 * This file is part of camEngine
 * 
 * camEngine - A 3d motor for ocaml
 * Copyright (C) 2009 DAVY Guillaume <davyg2@gmail.com>
 *
 * camEngine is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * camEngine is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with camEngine.  If not, see <http://www.gnu.org/licenses/>.
 *)
 
open Matrice;;
open Vec3d;;
open Vec2d;;
open Driver;;
open Scanf;;
open Scanning;;
open Array;;
open Mesh;;
open Node;;
open Camera;;

class scene = object (self)
	val mutable nList:(node list) = []
	val mutable d = new driver
	val mutable activeCamera = new camera
	
	method init (dr:driver) =
		d <- dr;
	
	method drawAll = 
		activeCamera#render;
		let rec aux = function
			| [] -> ()
			| h::q ->
				(h#render d);
				aux q
		in
		aux nList;
	
	method close = ();
	
	method addNode =
		let n = new node in
		nList <- (n::nList);
		n;
	
	method addMeshNode (m:mesh) =
		let n = new meshNode m in
		nList <- ((n :> node)::nList);
		n;
	
	method addCamera =
		let c = new camera in
		self#setActiveCamera c;
		c;
		
	method setActiveCamera (c:camera) =
		activeCamera <- c;
end;;


